package com.cjh.execption;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.sql.SQLIntegrityConstraintViolationException;

@ControllerAdvice
public class ExecptionResponse {

    @ExceptionHandler(value = InsertException.class)
    @ResponseBody
    public ApiResult InsertExceptionHandler(InsertException exception){
        System.out.println(exception.getMessage());
        return new ApiResult(500,exception.getMessage());
    }

}
